var PersonnelRecordList = {
	init: function(){
		var boss = this;
		
		boss.initLayout();
		boss.initEvent();
	},
	initLayout: function(){
		var boss = this;
		
		var pcs = modelDao.getDeptDict("1");
		for(var i = 0; i < pcs.length; i++){
			var item = pcs[i];
			var option = $("<option></option>").html(item.DEPTNAME).attr("value",item.ID);
			$("#pcs").append(option);
		}
		$("#startdate, #stopdate").datetimepicker();
		boss.initGrid();
	},
	initEvent: function(){
		var boss = this;
		
		$("#SearchBtn").bind("click", function(){
			boss.initGrid();
		});
		
		$("#pcs").bind("change", function(){
			var id = $(this).val();
			if(id != ""){
				var jq = modelDao.getDeptDict(id);
				$("#jq").empty();
				$("#jq").append("<option value=''>--请选择--</option>");
				for(var i = 0; i < jq.length; i++){
					var item = jq[i];
					var option = $("<option></option>").html(item.DEPTNAME).attr("value",item.ID);
					$("#jq").append(option);
				}
				$("#jq").show();
			}else{
				$("#jq").hide();
			}
		});
	},
	initGrid: function(){
		var boss = this;
		
		var data = sbl.getFormData("search_div");
		CardGrid.grid({
			url: burl + "/PersonnelRecord/getList.do",
			Data: data,
			columns: {
				img: "file1",
				title: "address",
				row1: ["personName,姓名", "personCardcode,身份证号"],
				row2: ["buildingCode,楼栋编码", "creatername,采集人", "createtime,采集时间"],
				todo: "operation"
			},
			OnRender: function(d){
				var todo = ["<a target='_blank' href='" + burl + "/view/manager/main.jsp?action=/PersonnelRecord/detail.do?id=" + d.personId + "&tag=detail'>详情</a>"];
				d.operation = CardGrid.getTodoHtml(todo);
				return d;
			}
		}, "personnel_record_grid");
	}
};
$(function(){
	PersonnelRecordList.init();
});